<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<title>新增外勤拜访</title>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />

<!--[if lt IE 9]>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/html5.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/respond.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/PIE_IE678.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/lib/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/lib/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/lib/Hui-iconfont/1.0.7/iconfont.css" />
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/css/sty.css">
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->
<style type="text/css">
	.f-w{font-weight: bold;}
    /*.input-text{border: none !important}*/
    /*textarea{width: 95% !important}*/
    td{font-size: 14px !important}
    .page-container{margin-bottom: 25px}
    button{margin-left: 20px }
    textarea,.Wdate{background-color: #fbfbfb !important}
    .textarea{height: 70px;width: 90%}
    .wq5{margin-top: 10px;margin-bottom: 10px;}
    .date1{padding-left: 27px !important}
    .textarea1{margin-top: 10px;}
    .a_c{float: right;padding-right: 100px;padding-top: 20px;color: blue}
</style>
</head>


<body>
<div class="page-container">
    <div class="mt-20 wq5" style="padding-bottom: 12px !important;padding-top: 12px !important">
    <form class="form form-horizontal" >
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>拜访客户：</label>
            <div class="formControls col-xs-8 col-sm-9 date1">
                <input name="cid" type="hidden" value="{$cid}" />
                <input type="text" class="input-text" value="{$client_name}" placeholder="请先点击选择客户" id="client_name" name="client_name" onclick="javascript:window.location.href='{:U("Out/choice")}'">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">拜访地点：</label>
            <div class="formControls col-xs-8 col-sm-9 date1">
                <input type="text" class="input-text" value="" placeholder="" id="location_in" name="location_in">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label  col-xs-4 col-sm-3" >拜访时间：</label>
            <div class="formControls col-xs-8 col-sm-9 date1">
                <input type="text"  onfocus="WdatePicker()" id="visit_time" name="visit_time" class="input-text Wdate" style="width:180px;">
            </div>
        </div>
        <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">沟通内容：</label>
                <input type="hidden" name="num" id="num" value="3" />  <!-- 存放内容行数量 -->  
                <div class="formControls col-xs-8 col-sm-9 col-sm-offset-1 input_box">
                    <label>1. </label><textarea name="content1" cols="" rows="" class="textarea"  placeholder="请输入总结内容" datatype="*10-100" dragonfly="true"  onKeyUp="textarealength(this,400)"></textarea>
                </div>
                <div class="formControls col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3 textarea1 input_box">
                    <label>2. </label><textarea name="content2" cols="" rows="8" class="textarea"  placeholder="请输入总结内容" datatype="*10-100" dragonfly="true"  onKeyUp="textarealength(this,400)"></textarea>
                </div>
                <div class="formControls col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3 textarea1 input_box">
                    <label>3. </label><textarea name="content3" cols="" rows="8" class="textarea"  placeholder="请输入总结内容" datatype="*10-100" dragonfly="true"  onKeyUp="textarealength(this,400)"></textarea>
                </div>
                <div class=""><a href="#" onclick="add()" class="a_c">新增一行 +</a></div>
            </div>
        <div class="row cl">
            <label class="form-label  col-xs-4 col-sm-3" >下次拜访时间：</label>
            <div class="formControls col-xs-8 col-sm-9 date1">
                <input type="text"  onfocus="WdatePicker()" id="appoint_time" name="appoint_time" class="input-text Wdate" style="width:180px;">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2 text-c">
                <button onclick="tj();" id="sub" class="btn btn-primary radius" type="button"><i class="Hui-iconfont">&#xe632;</i>添加</button>
                <button onclick="layer_close();" class="btn btn-default radius" type="button">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="__PUBLIC__/Admin/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="__PUBLIC__/Admin/lib/My97DatePicker/WdatePicker.js"></script>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<!-- <script type="text/javascript" src="../lib/webuploader/0.1.5/webuploader.min.js"></script>  -->
<script type="text/javascript">
// 添加新行
function add(){
    var len = $('.input_box').length + 1;
    var content = '<div class="formControls col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3 textarea1 input_box"><label>' + len + '. </label><textarea class="textarea" name="content' + len + '" placeholder="请输入总结内容" rows="8"  dragonfly="true" datatype="*10-100" onKeyUp="textarealength(this,400)"></textarea></div>';
    $('.input_box:last').after(content);
    $('#num').val(len);
}

function tj(){
    if( !$('#client_name').val() ){
        layer.msg('请先选择拜访客户',{icon:2,time:1000});
    }else if( $.trim($('#location_in').val()) == '' ){
        layer.msg('请填写拜访地点',{icon:2,time:1000});
    }else if( !$('#visit_time').val() ){
        layer.msg('请选择拜访时间',{icon:2,time:1000});
    }else{
        var con = 0; // 判断是否填写内容
        for (var i = 0; i < $('.textarea').length; ++i) {
            if($.trim($('.textarea').eq(i).val()) !== ''){  // 如果此行内容不为空
                con = 1; break;
            }
        }
        if(con == 1){
            $('#sub').attr('display','');
            $.ajax({  
                url: "{:U('Out/addCheck')}", 
                type: "POST",  
                data: $('form').serializeArray(), 
                success: function(msg){  
                    console.log(msg);
                    if(msg['state'] == 200){
                        layer.msg( msg['content'] ,{icon:1,time:1000});
                        setTimeout('parent.location.href = "{:U('Out/index')}"', 1000);
                    }else{
                        layer.msg( msg['content'] ,{icon:2,time:1000});
                        $('#sub').attr('display','tj()');
                    }
                }  
            });
        }else{
            layer.msg('请填写沟通内容',{icon:2,time:1000});
        }
    }
}


</script>
</body>
</html>